package com.example.hosptial.model.enity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.List;

@Data
@Entity
@Table(name = "nurse")
public class Nurse {
    @Id
    @Column(length = 20)
    private String nurseId;

    @NotBlank(message = "护士姓名不能为空")
    @Size(max = 50, message = "护士姓名长度不能超过50个字符")
    @Column(nullable = false, length = 50)
    private String nurseName;

    @Pattern(regexp = "^[男女]$", message = "性别只能是男或女")
    @Column(length = 1)
    private String nurseGender;

    @Min(value = 1, message = "年龄必须大于0")
    private Integer nurseAge;

    @NotBlank(message = "身份证号不能为空")
    @Pattern(regexp = "^\\d{17}[0-9X]$", message = "身份证号格式不正确")
    @Column(unique = true, nullable = false, length = 18)
    private String nurseIdCard;

    @Pattern(regexp = "^\\d{1,20}$", message = "电话号码格式不正确")
    @Column(length = 20)
    private String nursePhone;

    @ManyToOne
    @JoinColumn(name = "deptId")
    private Department department;

    @JsonBackReference
    @OneToMany(mappedBy = "nurse")
    private List<NurseWardAssignment> wardAssignments;
} 